// pages/mainindex/index.js
var app = getApp()
import http from "../../../../class/Utils/Http"
import tips from "../../../../class/Utils/Tips"
Page({

    /**
     * 页面的初始数据
     */
    data: {
        lista: [
            {name: '微营销解决方案', imgurl: 'https://toocle.y.netsun.com/xcximg/test-07.jpg',},
            {name: '供应链金融解决方案', imgurl: 'https://toocle.y.netsun.com/xcximg/test-05.jpg',},
            {name: '物流网络解决方案', imgurl: 'https://toocle.y.netsun.com/xcximg/test-09.jpg',},
            {name: '新流通管理软件', imgurl: 'https://toocle.y.netsun.com/xcximg/test-011.jpg',}
        ],
    },
    onLoad: function (e) {

        var that = this;
        var thatid = e.aa

        that.setData({
            dataid: thatid,
            mid:e.mid
        })
        console.log(that.data.dataid)
        var user = wx.getStorageSync('user');
        http.reqload("/Mingpian/chakan", {id: e.mid, uid: user.userid}, function (infores) {

            that.setData({
                info: infores,
            })
        })
        that.abc();

    },

    //监听 page 滚动条位置
    onPageScroll: function (res) {
        //console.log(res.scrollTop);
        if (res.scrollTop >= 167) {
            this.setData({
                floorstatus: true
            })
        } else {
            this.setData({
                floorstatus: false
            })
        }
    },
    //page 返回顶部 点击顶部时间未知也可返回顶部
    pagegotop: function (e) {
        wx.pageScrollTo({
            scrollTop: 0,
            duration: 300
        })
    },
    //
    abc: function () {
        var that = this
        var dataid = that.data.dataid
        var datalista = that.data.lista
        var listaurl = datalista[dataid].imgurl
        that.setData({
            imgurl: listaurl
        })

    },
    //去首页
    gotohome: function () {
        wx.switchTab({
            url: '/pages/index/index'
        })
    },
    //去名片
    gotowodemingpian: function (e) {
        wx.reLaunch({
            url: '/pages/mingpian/card/card?id=' + this.data.mid
        })
    },
    // //去旺铺
    // gotowangpu: function () {
    //     wx.reLaunch({
    //         url: '/pages/mingpian/wangpu/index/index?mid=' + this.data.mid
    //     })
    // },
    // //去企业介绍
    // gotojieshao: function () {
    //     wx.reLaunch({
    //         url: '/pages/mingpian/wangpu/jieshao/jieshao?mid=' + this.data.mid
    //     })
    // },

    gotowangpu:function(){
        var info = this.data.info
        if(info.wx_user.toocle_cid == 0){
            tips.error("暂无旺铺")
            return false
        }
        if(info.wx_user.toocle_cid==100387){
            tips.redirectTo('/pages/mingpian/wangpu/index/index?mid='+this.data.info.id);
        }else{
            tips.redirectTo("/pages/toocle/shop/index/index?cid="+info.wx_user.toocle_cid+"&time="+info.wx_user.toocle_ctime+"&quanmenuid=1");
        }

    },
    //去企业介绍
    gotojieshao:function(){
        var info = this.data.info
        if(info.wx_user.toocle_cid == 0){
            tips.error("暂无旺铺")
            return false
        }
        if(info.wx_user.toocle_cid==100387){
            tips.redirectTo('/pages/mingpian/wangpu/jieshao/jieshao?mid='+this.data.info.id);
        }else{
            tips.redirectTo("/pages/toocle/shop/index/index?cid="+info.wx_user.toocle_cid+"&time="+info.wx_user.toocle_ctime+"&quanmenuid=3");
        }
    },
})